home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 2
/
Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso
/
Aminet
/
dev
/
misc
/
egs.lha
/
EGS
/
EGS_Devels
/
Examples
/
EGS_Gadget
/
gadget1.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-02-17
|
7KB
|
258 lines
/*
** CHANGE : 30 Nov 1992 mvk
** 17 Dec 1992 mvk
** 09 Jan 1993 mvk
**
** This program describes the possibility of scaleable
**
** gadgets and so on. See important lines at the end of code
**
** (message handling !).
**
**
** (C) by VIONA-Development 1991,1993
**
*/
#include "includes.c"
void Crash (char * string);
struct Library *EGSIntuiBase;
struct Library *GfxBase;
struct Library *EGBBase;
struct Library *EGBScrollBase;
struct Library *EGBRadioBase;
struct Library *EGBSetBase;
struct Library *EGBSelectBase;
struct Library *EGBTextInfoBase;
EI_WindowPtr window;
EI_EIntuiMsgPtr msg;
EB_GadContext con;
EB_StrArray Gads1 = { " 8","13","18","24","40",NULL };
EB_StrArray Gads2 = { "OK","CANCEL",NULL };
EB_StrArray2 Gadgs = { &Gads1, &Gads2, NULL };
EI_WindowPtr CreateGads (EI_WindowPtr win)
{
EB_GadBoxPtr root, help, help2;
EI_GadgetPtr tgad;
con = EB_CreateGadContext(NULL,NULL,-1,-1);
if(con == NULL)
Crash("Cant't create Gadget context !");
root = EB_CreateHorizBox(con);
EB_AddLastSon(root, EB_CreateSuperVertiProp(con, 40, 20, 5, 0x2000,
EB_DEC_UP_LEFT | EB_INC_BOTTOM_RIGHT ));
EB_AddLastSon(root, EB_CreateHorizFill(con,0,0));
help = EB_CreateVertiBox(con);
EB_AddLastSon(help, EB_CreateVertiFill(con,0,0));
EB_AddLastSon(help, EB_CreateMultiAction2(con, &Gadgs,0x1000 ));
EB_AddLastSon(help, EB_CreateVertiFill(con,0,0));
EB_AddLastSon(help, EB_CreateSuperHorizProp(con, 20, 4, 5, 0x2001,
EB_DEC_UP_LEFT | EB_INC_BOTTOM_RIGHT ));
EB_AddLastSon(root, help);
EB_AddLastSon(root, EB_CreateHorizFill(con,0,0));
EB_AddLastSon(root, EB_CreateSuperVertiProp(con, 20, 4, 5, 0x2002,
EB_DEC_UP_LEFT | EB_INC_BOTTOM_RIGHT ));
EB_AddLastSon(root, EB_CreateHorizFill(con,0,0));
EB_AddLastSon(root, EGB_CreateLateScrollBox(con,20,40,10,20,1,0x3000));
EB_AddLastSon(root, EB_CreateHorizFill(con,0,0));
help = EB_CreateHorizBox(con);
EB_AddLastSon(help, EGB_CreateRadioGadget(con,&Gads1,100,0x4000));
EB_AddLastSon(help, EB_CreateHorizFill(con,0,0));
EB_AddLastSon(help, EGB_CreateSetGadget(con,&Gads1,100,0x4001));
help2 = EB_CreateVertiBox(con);
EB_AddLastSon(help2, help);
EB_AddLastSon(help2, EB_CreateVertiFill(con,0,0));
EB_AddLastSon(help2, EGB_CreateTextSelectGadget(con, 0x5000, &Gads1));
EB_AddLastSon(root,help2);
root = EB_CreateMasterWindow(con,win,root);
if (EB_ProcessGadBoxes(con,root))
{
tgad = EB_FindGadget(con->First, con->Num, 0x6000);
/*
** Filling in the EI_NewWindow structure
*/
if (win == NULL)
{
/* give more flags to the window */
con->NewWin->IDCMPFlags = EI_iCLOSEWINDOW |
EI_iNEWSIZE |
EI_iSIZEVERIFY |
EI_iGADGETUP;
con->NewWin->Bordef.SysGadgets |= (EI_WINDOWCLOSE | EI_WINDOWSIZE);
con->NewWin->MaxWidth = 800;
con->NewWin->MaxHeight = 600;
con->NewWin->Flags |= (EI_SIZEBRIGHT);
return (EI_WindowPtr)EI_OpenWindow(con->NewWin);
}else
return win;
}else
return NULL;
}
void Crash (char * string)
{
if (NULL != window)
EI_CloseWindow( window );
if (NULL != con)
EB_DeleteGadContext(con);
if (NULL != EGSIntuiBase)
CloseLibrary( EGSIntuiBase );
if (NULL != EGBBase)
CloseLibrary( EGBBase );
if (NULL != EGBScrollBase)
CloseLibrary( EGBScrollBase );
if (NULL != EGBRadioBase)
CloseLibrary( EGBRadioBase );
if (NULL != EGBSelectBase)
CloseLibrary( EGBSelectBase );
if (NULL != EGBTextInfoBase)
CloseLibrary( EGBTextInfoBase );
if (NULL != GfxBase)
CloseLibrary( GfxBase );
if (NULL == string)
exit (0);
else{
printf ("%s.\n", string);
exit (10);
}
}
void main (void)
{
window = NULL;
con = NULL;
EGSIntuiBase = OpenLibrary ( "egsintui.library", 0 );
if (NULL == EGSIntuiBase)
Crash ( "Could not open egsintui.library" );
GfxBase = OpenLibrary ( "graphics.library", 0 );
if (NULL == GfxBase)
Crash ( "Could not open gfx.library" );
EGBBase = OpenLibrary ( "egsgadbox.library", 0 );
if (NULL == EGBBase)
Crash ( "Could not open egsgadbox.library" );
EGBScrollBase = OpenLibrary ( "egb/gbscrollbox.library", 0 );
if (NULL == EGBScrollBase)
Crash ( "Could not open egb/gbscrollbox.library" );
EGBRadioBase = OpenLibrary ( "egb/gbradio.library", 0 );
if (NULL == EGBRadioBase)
Crash ( "Could not open egb/gbradio.library" );
EGBSetBase = OpenLibrary ( "egb/gbsets.library", 0 );
if (NULL == EGBSetBase)
Crash ( "Could not open egb/gbsets.library" );
EGBSelectBase = OpenLibrary ( "egb/gbselect.library", 0 );
if (NULL == EGBSelectBase)
Crash ( "Could not open egb/gbselect.library" );
EGBTextInfoBase = OpenLibrary ( "egb/gbtextinfo.library", 0 );
if (NULL == EGBTextInfoBase)
Crash ( "Could not open egb/gbtextinfo.library" );
window = CreateGads(NULL);
if (NULL == window)
Crash ("Could not open window");
/*
** Handle the messages like Amiga (extend with EI_)
*/
for (;;)
{
while (NULL == (msg = (EI_EIntuiMsgPtr) GetMsg ( window->UserPort )))
WaitPort ( window->UserPort );
switch (msg->Class)
{
case EI_iSIZEVERIFY:
printf("VerifySizing ! \n");
EI_RemoveGList(window,con->First,con->Num);
EB_DeleteGadContext(con);
ReplyMsg ( (struct Message*)msg );
break;
case EI_iNEWSIZE:
printf("Sizing ! \n");
EI_LockIntuition();
window=CreateGads(window);
EI_AddGList(window,con->First,con->Num);
EI_UnlockIntuition();
ReplyMsg ( (struct Message*)msg );
break;
case EI_iCLOSEWINDOW:
ReplyMsg ( (struct Message*)msg );
Crash (NULL);
break;
default:
printf (" Unknown message %ld\n", msg->Class);
ReplyMsg ( (struct Message*)msg );
}
} /* forever */
}